home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-12-11 | 3.3 KB | 118 lines | [TEXT/MPS ] |
- /*
- File: Command.h
-
- Contains: Command Classes Definition
-
- Written by: Dave Stafford
-
- Copyright: © 1995 by Apple Computer, Inc., all rights reserved.
- */
-
- // -- Compiler/Preprocessor Switches --
-
- #ifndef _COMMAND_
- #define _COMMAND_
-
- #ifndef _COMPILERDEFS_
- #include "CompDefs.h"
- #endif
-
- #ifndef _DRAWEDITORDEF_
- #include "DrawEditorDef.h"
- #endif
-
- //=============================================================================
- // Forward Declarations
- //=============================================================================
- class DrawEditor;
-
- //=============================================================================
- // Constants
- //=============================================================================
-
- //=============================================================================
- // Enumerations
- //=============================================================================
-
-
- //=============================================================================
- // CCommand
- //
- // Assumptions:
- // The command object assumes that for all Begin/End action pairs, the SAME
- // command object will be used. In this case, null is written out for the begin
- // action, and the this pointer for the command is written out for all other
- // action types. This also means that commit will only be called once on such
- // commands.
- //
- //=============================================================================
- class CCommand
- {
- public:
-
- // -- Init --
- CCommand(DrawEditor* theEditor,
- ODBoolean canUndo = kODFalse,
- ODBoolean changesContent = kODFalse,
- ODID undoTextIndex = kUndoCommandIndex,
- ODID redoTextIndex = kRedoCommandIndex);
-
- virtual ~CCommand();
-
- public:
-
- // -- Accessors --
- void SetChangesContent(ODBoolean changesContent);
-
- void SetMenuTextIDs(ODID undoTextIndex, ODID redoTextIndex);
-
- ODBoolean CanUndo() const;
- ODBoolean ChangesContent() const;
- ODCommandID GetCommandID() const;
-
- // -- Actions --
- void SetActionType(ODActionType actionType);
- ODActionType GetActionType() const;
- void WriteAction(Environment* ev, ODActionType actionType);
- void AbortCommand(Environment* ev);
-
- // Undo-able commands
- // Should call inherited in derivative classes
- virtual void UndoCommand(Environment* ev);
- virtual void RedoCommand(Environment* ev);
-
- // Is called from DoCommand. Used to store information
- // about the command ( shapelists, etc. ).
- virtual void CaptureCommandState(Environment* ev);
-
- // Called just before the command is deleted.
- virtual void Commit(Environment* ev, ODDoneState state);
-
- // -- Must Override this method --
- // This method should only be called once per instance
- // Should call inherited in derivative classes
- virtual void DoCommand(Environment* ev);
-
-
- //----------------------------------------------------------------------------------------
- // Data Members
- //
- protected:
- ODBoolean fCanUndo; // Default True
- ODBoolean fChangesContent; // Default True
- ODActionType fActionType; // Default = kODSingleAction
- DrawEditor* fDrawEditor;
- ODFrame* fFrame; // Can be NULL
-
- private:
- ODUndo* fUndo;
- ODDoneState fDoneState; // doneState values are kODDone, kODUndone, or kODRedone (ODTypes.h)
-
- ODID fUndoTextIndex; // For Undo menu item. Default: kUndoCommandIndex
- ODID fRedoTextIndex; // For Redo menu item. Default: kRedoCommandIndex
- };
-
-
-
-
- #endif